/*
*******************************************************************************
*                              (c) Copyright HighSun Techonology Company
*                                           All Rights Reserved
*
* File    : memory_handle.c
* By      : HuangXi
* Version : V0.1
* Datetime: 2012-02-12 AM 12:23
* Description: For  memory operation
*******************************************************************************
*/

/* Copy memory to memory */
void mem_cpy (void* dst, const void* src, long cnt) 
{
	char *d = (char*)dst;
	const char *s = (const char *)src;
	while (cnt--) *d++ = *s++;
}

/* Fill memory */
void mem_set (void* dst, long val, long cnt) 
{
	char *d = (char*)dst;
	while (cnt--) *d++ = (char)val;
}

/* Compare memory to memory */
int mem_cmp (const void* dst, const void* src, long cnt) 
{
	const char *d = (const char *)dst, *s = (const char *)src;
	long r = 0;
	while (cnt-- && (r = *d++ - *s++) == 0) ;
	return r;
}

